home *** CD-ROM | disk | FTP | other *** search
/ SGI Hot Mix 17 / Hot Mix 17.iso / HM17_SGI / research / examples / misc / sdf / ncdf_cat.pro < prev    next >
Text File  |  1997-07-08  |  1KB  |  42 lines

  1. ;
  2. ;    Test program: CATalog of a NetCDF file
  3. ;
  4. pro ncdf_cat,filename
  5.  
  6.     cdfid = ncdf_open(filename,/NOWRITE)    ; Open the file
  7.     glob = ncdf_inquire( cdfid )        ; Find out general info
  8.  
  9.     ;    Show user the size of each dimension
  10.  
  11.     print,'Dimensions', glob.ndims
  12.     for i=0,glob.ndims-1 do begin
  13.         ncdf_diminq, cdfid, i, name,size
  14.         if i EQ glob.recdim then    $
  15.             print,'    ', name, size, '(Unlimited dim)'    $
  16.         else            $
  17.             print,'    ', name, size
  18.         
  19.     endfor
  20.  
  21.     ;    Now tell user about the variables
  22.  
  23.     print
  24.     print, 'Variables'
  25.     for i=0,glob.nvars-1 do begin
  26.  
  27.         ;    Get information about the variable
  28.         info = ncdf_varinq(cdfid, i)
  29.         FmtStr = '(A," (",A," ) Dimension Ids = [ ", 10(I0," "),$)'
  30.         print, FORMAT=FmtStr, info.name,info.datatype, info.dim[*]
  31.         print, ']'
  32.  
  33.         ;    Get attributes associated with the variable
  34.         for j=0,info.natts-1 do begin
  35.             attname = ncdf_attname(cdfid,i,j)
  36.             ncdf_attget,cdfid,i,attname,attvalue
  37.             print,'    Attribute ', attname, '=', string(attvalue)
  38.         endfor
  39.     endfor
  40.     ncdf_close,cdfid    ; done
  41. end
  42.